<?php
/**
 * redis操作基类
 * User: wangyongqiang
 * Date: 2017/10/13 10:44
 */
class redisClass{
    public $handle;

    public function __construct($options = array())
    {
        if(!extension_loaded('redis')) exit('NO SUPPORT REDIS');

        $this->handle = new Redis();
        $this->handle->connect($options['host'], $options['port']);
        if(isset($options['pass'])) $this->handle->auth($options['pass']);
        if(isset($options['db'])) $this->handle->select($options['db']);
    }

    public function get($name){
        return $this->handle->get($name);
    }

    public function delete($name){
        return $this->handle->get($name);
    }

    public function rpush($name, $jsonval){
        return $this->handle->rPush($name, $jsonval);
    }

    public function hset($key, $field, $val){
        return $this->handle->hSet($key, $field, $val);
    }

}